package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.anno.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

@Mapper
public interface DishMapper {

    //根据菜品id差菜品信息【单个】
    @Select("select * from dish where id=#{dishId}")
    Dish selectById(Long dishId);

    @Select("select count(*) from dish where category_id=#{id}")
    Integer selectByCategoryID(Long id);

    @AutoFill(OperationType.INSERT)
    void insertOne(Dish dish);

    //-2--分页
    Page<DishVO> selectPage(DishPageQueryDTO dishPageQueryDTO);


    //-3--起售的菜品id
    Integer countByStatusAndIds(List<Long> ids);

    void deleteByIds(List<Long> ids);

    @Select("select * from dish where id=#{id}")
    Dish getDishById(Long id);


    //修改
    @AutoFill(OperationType.UPDATE)
    void updateDish(Dish dish);

    @Update("update dish set status=#{status} where id=#{id}")
    void updateDishStatus(Integer status, Long id);


    //根据分类id查询菜品
    @Select("select * from dish where category_id=#{id}")
    List<Dish> selectDishByCategoryId(Long categoryId);




    Integer countByMap(Map paramMap);
}
